package com.damai.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.citywithincity.utils.HexUtil;

public class SecurityUtils {
	
	/**
	 * 
	 * @param strSrc
	 * @return
	 */
	 public static String sha256(String strSrc) {
	        MessageDigest md = null;
	        String strDes = null;
	        byte[] bt = strSrc.getBytes();
	        try {
	            md = MessageDigest.getInstance("SHA-256");
	            md.update(bt);
	            strDes = HexUtil.encodeHexStr(md.digest()); // to HexString
	            return strDes;
	        } catch (NoSuchAlgorithmException e) {
	            throw new RuntimeException(e);
	        }
	       
	    }
}
